import java.util.Arrays;

//T 一定是 Number 的子类
class TestGeneric<T extends Number> {

}

class Alg<T extends Comparable<T>> {
    public T findMaxValue(T[] array) {
        T max = array[0];
        for (int i = 1; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;
    }
}

class Alg2 {
    public <T extends Comparable<T>> T findMaxValue(T[] array) {
        T max = array[0];
        for (int i = 1; i < array.length; i++) {
            if (max.compareTo(array[i]) < 0) {
                max = array[i];
            }
        }
        return max;
    }
}

public class Test {
    public static void main(String[] args) {
        Alg2 alg2 = new Alg2();
        Integer[] integers = {1, 2, 3, 4, 5, 6};
        Integer ret = alg2.<Integer>findMaxValue(integers);
        System.out.println(ret);//6
    }

    public static void main2(String[] args) {
        Alg<Integer> alg = new Alg<>();
        Integer[] integers = {1, 2, 3, 4, 5, 6};
        Integer ret = alg.findMaxValue(integers);
        System.out.println(ret);
    }

    public static void main1(String[] args) {
        /*TestGeneric<Number> testGeneric1 = new TestGeneric<>();
        TestGeneric<Integer> testGeneric2 = new TestGeneric<>();
        TestGeneric<Double> testGeneric3 = new TestGeneric<>();

        TestGeneric<String> testGeneric4 = new TestGeneric<>();*/

    }
}
